package org.john.lfu;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;

/**
 * Created by adsame on 17-1-24.
 */
public class LFUImpl {
    public static void main(String args[]) {
//        LFUCache cache = new LFUCache(10, 0.1f);
//        HashMap map = new HashMap<Integer, Integer>();
//        for (int i = 1; i <= 15; ++i) {
//            int rand = new Random().nextInt(20);
//            System.out.print(rand + ";");
//            if (map.containsKey(rand)) {
//                map.put(rand, (Integer)map.get(rand) + 1);
//            } else {
//                map.put(rand, 1);
//            }
//            if (cache.containsKey(rand)) {
//                cache.put(rand, (Integer)cache.get(rand) + 1);
//            } else {
//                cache.put(rand, 1);
//            }
//        }
//        System.out.println();
//        System.out.println("map num:" + map.size() + "," + map);
//        System.out.println("cache:" + cache.keySet());
//        for (Object i : cache.keySet()) {
//            System.out.print(i + ":" + cache.frequencyOf(i) + ";");
//        }
////        for (int i = 0; i < 100; ++i) {
////            int freq = (Integer)cache.get(1);
////            cache.put(1, freq + 1);
////        }
//        System.out.println();
//        System.out.println("freq 1:" + cache.frequencyOf(1));
//        System.out.println("get 1:" + cache.get(1));
//        System.out.println("freq 1:" + cache.frequencyOf(1));
//        cache.get(2);
//        System.out.println("freq 2:" + cache.frequencyOf(2));
    }
}
